Re: [GENERAL] Updating multiple fields

Поиск
Список
Период
Сортировка
От lynch@lscorp.com (Richard Lynch)
Тема Re: [GENERAL] Updating multiple fields
Дата
Msg-id v02140b73b1b94e8e4af0@[207.152.64.133]
обсуждение исходный текст
Список pgsql-general
At 10:20 AM 6/26/98, Joao Paulo Felix wrote:
>Hello there,
>
>I have the following fields description, info and title.
>Is there a PostgreSQL query to update more than one field at the same
>time?
>
>Right now I have the following (I am using it with PHP, so please
>desregard its code):
>
>pg_Exec($conn, "UPDATE options SET description = '$description'
>        WHERE product = '$product' AND title = '$old_title';");
>
>pg_Exec($conn, "UPDATE options SET info = '$info'
>        WHERE product = '$product' AND title = '$old_title';");
>
>pg_Exec($conn, "UPDATE options SET title = '$title'
>        WHERE product = '$product' AND title = '$old_title';");

Hey!  One I can answer!

typos may exist:

pg_Exec($conn, "UPDATE options SET description = '$description', info =
'$info', title = '$title' WHERE product = '$product' AND title =
'$old_title'");

Basically, you can have as many ", field = $value" entries as you like.

I also purposefully stripped off the ';' inside the string because
PostgreSQL doesn't need it, and some other database backend barfs when you
use it, so if you ever want to port, you don't want the ';' as part of the
SQL.  Capiche?

--
--
-- "TANSTAAFL" Rich lynch@lscorp.com



В списке pgsql-general по дате отправления:

Предыдущее
От: Joao Paulo Felix
Дата:
Сообщение: Updating multiple fields
Следующее
От: Brian
Дата:
Сообщение: Are there any books